package com.ruoyi.hospital.controller.statistics;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.hospital.dto.HotDoctor;
import com.ruoyi.hospital.dto.HotDrug;
import com.ruoyi.hospital.dto.Nums;
import com.ruoyi.hospital.dto.Piedate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.ruoyi.common.core.domain.AjaxResult.success;

/**
 * 管理端-首页统计
 * */
@RestController
@RequestMapping("/hospital/managerStatistics")
public class ManagerStatistics {

    @Autowired
    private RedisCache redisCache;
    //首页的统计
    @GetMapping(value = "/nums")
    public AjaxResult getnums()
    {
        //数字统计
        Nums nums = new Nums();
        try{
             nums = (Nums)redisCache.getCacheObject("nums");
        }catch (Exception e){

        }
        return success(nums);
    }


    //图形和列表统计
    @GetMapping(value = "/conDate")
    public AjaxResult getconDate(){
        //图形和列表统计
        List<Piedate> conDate = redisCache.getCacheList("conDate");
        return success(conDate);
    }


    //药店销量统计
    @GetMapping(value = "/storeData")
    public AjaxResult storeData(){
        //图形和列表统计
        List<Piedate> storeData = redisCache.getCacheList("storeData");
        return success(storeData);
    }



    //热门医生
    @GetMapping(value = "/hotDoctor")
    public AjaxResult hotDoctor(){
        //图形和列表统计
        List<HotDoctor> hotDoctor = redisCache.getCacheList("hotDoctor");
        return success(hotDoctor);
    }

    //热销药品
    @GetMapping(value = "/hotDrug")
    public AjaxResult hotDrug(){
        //图形和列表统计
        List<HotDrug> hotDrug = redisCache.getCacheList("hotDrug");
        return success(hotDrug);
    }

}
